package com.zhoukai.business.util.license;

import com.alibaba.fastjson.JSON;
import lombok.SneakyThrows;

public class LicenseContentManager {

    private volatile static LicenseContent licenseContent;

    @SneakyThrows
    public static LicenseContent instance(String licenseString, String secretKey) {
        if (licenseContent == null) {
            synchronized (LicenseContentManager.class) {
                if (licenseContent == null) {
                    // 解密
                    String decryptContent = EncryptUtil.decrypt(licenseString, secretKey);
                    licenseContent = JSON.parseObject(decryptContent, LicenseContent.class);
                }
            }
        }
        return licenseContent;
    }

    public static LicenseContent instance() {
        return licenseContent;
    }

}
